﻿using Huioo.Learning.Agile.Payroll.Domain;
using Huioo.Learning.Agile.Payroll.Infrastructure;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Huioo.Learning.Agile.Payroll.Application
{
    public class PaydayTransaction : Transaction
    {
        public void Execute()
        {
            ArrayList empIds = PayrollDatabase.GetAllEmployeeIds();
            foreach (int empId in empIds)
            {
                Employee employee = PayrollDatabase.GetEmployee(empId);
                if (employee.IsPayDate(payDate))
                {
                    //Paycheck pc = new Paycheck(payDate);

                    DateTime startDate = employee.GetPayPeriodStartDate(payDate);
                    Paycheck pc = new Paycheck(startDate, payDate);
                    paychecks[empId] = pc;
                    employee.Payday(pc);
                }
            }
        }

    }
}
